package com.ai.util;

import java.io.IOException;
import java.util.ArrayList;

import com.ai.academiainteligente.R;
import com.ai.util.CategoryAdapter.ViewHolder;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ComentarioAdapter extends BaseAdapter {

	ArrayList<Comentario> comentarios;

	public ComentarioAdapter(ArrayList<Comentario> comentarios) {
		this.comentarios = comentarios;
	}

	@Override
	public int getCount() {

		return comentarios.size();
	}

	@Override
	public Object getItem(int arg0) {

		return comentarios.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Comentario comentario = comentarios.get(position);

		Context ctx = parent.getContext();

		ViewHolder holder;

		if (convertView == null) {
			convertView = LayoutInflater.from(parent.getContext()).inflate(
					R.layout.item_comentario, null);
			holder = new ViewHolder();
			holder.nome = (TextView) convertView.findViewById(R.id.textView1);
			holder.descricao = (TextView) convertView
					.findViewById(R.id.textView2);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.nome.setText(comentario.getNome());
		holder.descricao.setText(comentario.getTexto());

		return convertView;
	}

	static class ViewHolder {
		TextView nome;
		TextView descricao;
	}
}
